package com.yd.app.mapper;

import com.yd.domain.business.GoodsWeight;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商品规格Mapper
 * Created by sunxianhui on 2018/3/9.
 */
@Repository
public interface GoodsWeightMapper {

    /**
     * 添加商品规格
     * @param goodsWeight
     */
    @Insert("insert into business_goods_weight (id,goodsId,minWeight,maxWeight,jgf) values (#{goodsWeight.id},#{goodsWeight.goodsId},#{goodsWeight.minWeight},#{goodsWeight.maxWeight},#{goodsWeight.jgf})")
    int addGoodsWeight(@Param("goodsWeight") GoodsWeight goodsWeight);

    /**
     * 修改
     * @param goodsWeight
     */
    @Update("update business_goods_weight set goodsId=#{goodsWeight.goodsId},minWeight=#{goodsWeight.minWeight},maxWeight=#{goodsWeight.maxWeight},jgf=#{goodsWeight.jgf} where id=#{goodsWeight.id}")
    int updateGoodsWeight(@Param("goodsWeight") GoodsWeight goodsWeight);

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from business_goods_weight where id=#{id}")
    int deleteGoodsWeightById(@Param("id") String id);

    /**
     * 根据goodsId删除
     * @param goodsId
     */
    @Delete("delete from business_goods_weight where goodsId=#{goodsId}")
    int deleteGoodsWeightByGoodsId(@Param("goodsId") String goodsId);

    /**
     * 查找
     * @param goodsId
     */
    @Select("select * from business_goods_weight where goodsId=#{goodsId} ")
    List<GoodsWeight> getGoodsWeight(@Param("goodsId") String goodsId);

    /**
     * 根据条件分页查询
     * @param goodsId
     * @param startRow
     * @param pageSize
     * @return
     */
    @Select("select * from business_goods_weight where orderId=#{orderId} and goodsId=#{goodsId} ")
    List<GoodsWeight> getGoodsWeightList(@Param("goodsId") String goodsId, @Param("startRow") int startRow, @Param("pageSize") int pageSize);

}
